package net.zjitc.servlet;

import net.zjitc.domain.user;
import net.zjitc.service.UserService;
import net.zjitc.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

/**
 * @Author admin
 * @Date 2019/3/6 14:51
 */
@WebServlet(name = "CenterUIServlet",urlPatterns = "/centerUI")
public class CenterUIServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int uid = Integer.parseInt(request.getParameter("uid"));
        UserService service = new UserServiceImpl();
        user user = null;
        try {
            user = service.findByID(uid);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        request.setAttribute("u",user);
        request.getRequestDispatcher("/WEB-INF/center.jsp").forward(request,response);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
